package com.vibration.matlab;

import com.mathworks.toolbox.javabuilder.MWException;
import com.mathworks.toolbox.javabuilder.MWLogicalArray;
import com.mathworks.toolbox.javabuilder.MWNumericArray;
import com.mathworks.toolbox.javabuilder.MWStructArray;
import getA.GetAParameters;

import java.beans.IntrospectionException;

/**
 * 得到A的参数
 */
public class GetA {

    /**
     * 测试getA函数
     */
    public static TransInfo getA(A a) throws MWException, IntrospectionException {

        TransInfo transInfo=new TransInfo();

        GetAParameters getAParameters=new GetAParameters();

        MWStructArray matA = MWStructArray.fromBean(a);
        Object[] res=getAParameters.getA(7,matA);

        /**
         * 得到pol 三维矩阵
         */
        MWNumericArray getPol=(MWNumericArray)res[0];
        double[][][] pol=(double[][][])getPol.toDoubleArray();
        a.setPol(pol);
        /**
         * 得到limseg 二维矩阵
         */
        MWNumericArray getlimseg=(MWNumericArray)res[1];
        double[][] limseg=(double[][])getlimseg.toDoubleArray();
        a.setLimseg(limseg);
        /**
         * 得到polHHS 二维矩阵
         */
        MWNumericArray getpolHHS=(MWNumericArray)res[2];
        double[][] polHHS=(double[][])getpolHHS.toDoubleArray();
        a.setPolHHS(polHHS);
        /**
         * 得到facHHS矩阵
         */
        MWNumericArray getfacHHS=(MWNumericArray)res[3];
        double[][] facHHS=(double[][])getfacHHS.toDoubleArray();
        a.setFacHHS(facHHS);
        /**
         *得到ProbLimSupSegHHS矩阵
         */
        MWNumericArray getProbLimSupSegHHS=(MWNumericArray)res[4];
        double[][] ProbLimSupSegHHS=(double[][]) getProbLimSupSegHHS.toDoubleArray();
        a.setProbLimSupSegHHS(ProbLimSupSegHHS);

        /**
         * 得到LimVelSegHHS矩阵
         */
        MWNumericArray getLimVelSegHHS=(MWNumericArray)res[5];
        double[][] LimVelSegHHS=(double[][])getLimVelSegHHS.toDoubleArray();
        a.setLimVelSegHHS(LimVelSegHHS);
        /**
         * 得到HHS MWLogicalArray
         */
        MWLogicalArray getHHS=(MWLogicalArray)res[6];
        boolean HHS=getHHS.getBoolean(1);
        if(HHS==false){
            int[][] HS1={{0}};
            a.setHHS(HS1);
        }
        else{
            int[][] HS1={{1}};
            a.setHHS(HS1);
        }
        transInfo.setA(a);
        return transInfo;
    }
}
